<template>
  <div>
    <el-button
      size="mini"
      type="text"
      icon="el-icon-check"
      @click="handleApply"
    >提交申请</el-button>
    <el-button
      size="mini"
      type="text"
      icon="el-icon-edit"
      @click="_handleUpdate"
    >修改</el-button>
    <el-button
      size="mini"
      type="text"
      icon="el-icon-delete"
      @click="_handleDelete"
    >删除</el-button>
  </div>
</template>

<script>
  import { startProcess } from "@/api/activiti/monitor";
  export default {
    name: "ApplyBefore",
    props: {
      // 业务数据id
      dataId:{},
      // 模板编码
      processKey:{},
      // 业务数据关联表名
      module:{},
      /* 表格行数据 */
      row: {
        type: Object,
      },
      handleUpdate: {
        type: Function,
      },
      handleDelete: {
        type: Function,
      },
    },
    methods: {
      handleApply: function () {
        const id = this.row.id;
        this.$confirm('是否提交ID为"' + id + '"的申请单据?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(()=>{
          let data = {
            dataId : this.dataId,
            processKey : this.processKey,
            module : this.module,
            variables:{}
          }
          startProcess(data).then(res=>{
            if(res.code==200){
              this.$emit('getList');
              this.$message.success("申请成功")
            }
          })
        })
      },
      _handleUpdate: function () {
        this.handleUpdate(this.row);
      },
      _handleDelete: function () {
        this.handleDelete(this.row);
      },
    },
  }
</script>

<style scoped>

</style>
